/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practica.pkg1.mercurial;

import java.util.ArrayList;

/**
 *
 * @author RIVERA
 */
public class MainFrame extends javax.swing.JFrame {
    
    static System system=new System();
    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
        Initialization();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        ProductsButton = new javax.swing.JButton();
        BuyButton = new javax.swing.JButton();
        MainPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("VELVUANA INC.");

        jToolBar1.setRollover(true);

        ProductsButton.setText("VER PRODUCTOS");
        ProductsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ProductsButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(ProductsButton);

        BuyButton.setText("REALIZAR COMPRA");
        BuyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BuyButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(BuyButton);

        MainPanel.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(157, 157, 157)
                                .addComponent(jLabel1))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 90, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    private void ProductsButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
        ListOfProducts listP=new ListOfProducts(); 
        MainPanel.setVisible(false);
        MainPanel.removeAll();
        MainPanel.add(listP);
        MainPanel.setVisible(true);
    }                                              

    private void BuyButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Purchase pur= new Purchase();
        pur.setVisible(true);
    }                                         

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton BuyButton;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JButton ProductsButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration                   

    private void Initialization() {
         ArrayList<Wood> ListW =new ArrayList();
         Wood W1 =new Wood();
         Wood W2 =new Wood();
         Wood W3 =new Wood();
         Wood W4 =new Wood();
         Wood W5 =new Wood();
         
         W1.setType("Cherry");
         W1.setPrice(5.95);
         W1.setDeliveryTime(0.5);
         
         W2.setType("Curly Maple");
         W2.setPrice(6.0);
         W2.setDeliveryTime(1.5);
         
         W3.setType("Genuine Mahogany");
         W3.setPrice(9.60);
         W3.setDeliveryTime(3.0);
         
         W4.setType("Wenge");
         W4.setPrice(22.35);
         W4.setDeliveryTime(5.0);
         
         W5.setType("White Oak");
         W5.setPrice(6.70);
         W5.setDeliveryTime(1.5);
        
         ListW.clear();
         ListW.add(W1);
         ListW.add(W2);
         ListW.add(W3);
         ListW.add(W4);
         ListW.add(W5);
         
         
         system.setListOfWood(ListW);
         
         
         
    }
}
